#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <conio.h>
#include <iostream>
using namespace std;

typedef struct Project
{
    char projectName[999];
    char projectUserName[432];
    short projectStatus; //0为未开始，1为进行中，2为已完成
    short projectAwards; //0为未获奖，1为1等奖，2为2等奖，3为三等奖
    struct Project *nextProject;
} Project, *ProjectList;

typedef struct Thesis
{
    int id;
    char thesisName[999];
    char thesisUserName[432];
    short thesisStatus; //0为未开始，1为进行中，2为已完成
    short thesisAwards; //0为未获奖，1国家级，2为省部级，3为市厅级,4为校级
    short thesisType;   //0为SCI，1为EI，2为核心，3为一般
    struct Thesis *nextThesis;
} Thesis, *ThesisList;
typedef struct Essay
{
    char essayName[999];
    struct Essay *nextEssay;
    // Essay(char x[999]) : essayName(x[999]), nextEssay(NULL) {}
} Essay, *EssayList;

typedef struct User
{
    char name[10]; //姓名
    User *nextUser;
    Project *nextProject;
    Thesis *nextThesis;
    Essay *nextEssay;
    User(char name[10])
    { //显式构造函数,每次对新声明的节点类的对象进行初始化
        name = name;
        nextUser = NULL;
        nextProject = NULL;
        nextThesis = NULL;
        nextEssay = NULL;
    }

} UserL, *UserList;

UserList InitUser()
{
    UserList head = (UserList)malloc(sizeof(User));
    head->nextUser = NULL;
    head->nextProject = NULL;
    head->nextThesis = NULL;
    head->nextEssay = NULL;
    if (NULL == head)
    {
        printf("链表动态分配失败！程序终止！\n");
        exit(-1);
    }
    return head;
}
UserList AddUser(UserList head, char name[10])
{
    UserList user = (UserList)malloc(sizeof(User));
    if (head->nextUser == NULL)
    {
        head->nextUser = user;
    }
    else
    {
        while (head->nextUser != NULL)
        {
            head = head->nextUser;
        }
        head->nextUser = user;
    }
    user->nextUser = NULL;
    user->nextProject = NULL;
    user->nextThesis = NULL;
    user->nextEssay = NULL;
    return user;
}
void AddProject(UserList user, char projectName[999],
                char projectUserName[432],
                short projectStatus,
                short projectAwards )
{
    ProjectList project = (ProjectList)malloc(sizeof(Project));
    ProjectList temp = (ProjectList)malloc(sizeof(Project));
    project->essayName[999] = essayName[999];
    if (user->nextEssay == NULL)
    {
        user->nextProject = project;
        project->nextProject = NULL;
    }
    else
    {
        temp = user->nextProject;
        while (temp->nextProject != NULL)
        {
            temp = temp->nextProject;
        }
        temp->nextProject = project;
        project->nextProject = NULL;
    }
}
void AddEssay(UserList user, char essayName[999])
{
    EssayList essay = (EssayList)malloc(sizeof(Essay));
    EssayList temp = (EssayList)malloc(sizeof(Essay));
    if (temp->nextEssay == NULL)
        essay->essayName[999] = essayName[999];
    if (user->nextEssay == NULL)
    {
        user->nextEssay = essay;
        essay->nextEssay = NULL;
    }
    else
    {
        temp = user->nextEssay;
        while (temp->nextEssay != NULL)
        {
            temp = temp->nextEssay;
        }
        temp->nextEssay = essay;
        essay->nextEssay = NULL;
    }
    temp->nextEssay = essay;
}

void AddEssay(UserList user, char essayName[999])
{
    EssayList essay = (EssayList)malloc(sizeof(Essay));
    EssayList temp = (EssayList)malloc(sizeof(Essay));
    if (temp->nextEssay == NULL)
        essay->essayName[999] = essayName[999];
    if (user->nextEssay == NULL)
    {
        user->nextEssay = essay;
        essay->nextEssay = NULL;
    }
    else
    {
        temp = user->nextEssay;
        while (temp->nextEssay != NULL)
        {
            temp = temp->nextEssay;
        }
        temp->nextEssay = essay;
        essay->nextEssay = NULL;
    }
    temp->nextEssay = essay;
}

int main(int argc, char const *argv[])
{
    UserList temp, head;
    char name[10] = "fadsf";
    char essayName[999] = "trweyusfdghfhjdfghj";
    head = InitUser();
    temp = AddUser(head, name);
    AddEssay(temp, essayName);
    AddEssay(temp, essayName);
    AddEssay(temp, essayName);
    AddEssay(temp, essayName);
    system("pause");
    return 0;
}
